from abc import ABC, abstractmethod

# 抽象产品类
class Product(ABC):
    @abstractmethod
    def operation(self):
        pass

# 具体产品A
class ConcreteProductA(Product):
    def operation(self):
        return "ConcreteProductA的操作"

# 具体产品B
class ConcreteProductB(Product):
    def operation(self):
        return "ConcreteProductB的操作"

# 工厂类
class Factory:
    @staticmethod
    def create_product(product_type):
        if product_type == "A":
            return ConcreteProductA()
        elif product_type == "B":
            return ConcreteProductB()
        else:
            raise ValueError("未知的产品类型")

# 使用示例
def main():
    factory = Factory()
    
    # 创建产品A
    product_a = factory.create_product("A")
    print(product_a.operation())
    
    # 创建产品B
    product_b = factory.create_product("B")
    print(product_b.operation())

if __name__ == "__main__":
    main()


# 运行结果
# ConcreteProductA的操作
# ConcreteProductB的操作